//
//  PositionBtn.m
//  TengyunStation
//
//  Created by Johnny on 15/9/13.
//  Copyright (c) 2015年 xingrong. All rights reserved.
//

#import "PositionBtn.h"
#import "TSHeader.h"

@implementation PositionBtn

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        _activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        _activity.center = CGPointMake(frame.size.width/2.0, frame.size.height/2.0);
        [self addSubview:_activity];
        self.titleLabel.font = [UIFont systemFontOfSize:18];
        [self setTitleColor:OrangeColor forState:UIControlStateNormal];
        [self setTitle:@"点击获取编号" forState:UIControlStateNormal];
    }
    return self;
}

- (void)startGetPosition {
    [self setTitle:@"" forState:UIControlStateNormal];
    self.userInteractionEnabled = NO;
    _activity.hidden = NO;
    [_activity startAnimating];
}

- (void)stopGetPositionIsSuccess:(BOOL)isSuccess {
    if (!isSuccess) {
        self.userInteractionEnabled = YES;
        [self setTitle:@"点击获取编号" forState:UIControlStateNormal];
    }
    _activity.hidden = YES;
    [_activity stopAnimating];
}

@end
